Skip to content

[Refactor] Extract shared delivery upsert - #6056

Closed
oforiwaasam wants to merge 4 commits into
Agenta-AI:mainfrom
oforiwaasam:refactor/extract-shared-delivery-upsert
Closed

[Refactor] Extract shared delivery upsert#6056
oforiwaasam wants to merge 4 commits into
Agenta-AI:mainfrom
oforiwaasam:refactor/extract-shared-delivery-upsert

Conversation

@oforiwaasam

@oforiwaasam oforiwaasam commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

write_delivery, write_subscription_delivery_if_live (both in api/oss/src/dbs/postgres/triggers/dao.py), and SessionStreamsDAO.claim_trigger_delivery (api/oss/src/dbs/postgres/sessions/streams/dao.py) each independently rebuild the same column-values dict, index_elements, and index_where for the delivery upsert. The conflict target and the skipped-column rules can drift between the three copies without any test catching it.

Changes

Added a new helper module: api/oss/src/dbs/postgres/triggers/upsert_utils.py that centralizes building the trigger-delivery values dict and the index_elements / index_where conflict target. Replaced the duplicated logic in TriggersDAO.write_delivery, TriggersDAO.write_subscription_delivery_if_live, and SessionStreamsDAO.claim_trigger_delivery so they call the helper. No behavior changes were made.

Testing

Verified locally

To ensure testing efficiency, I first ran uv run --no-sync python run-tests.py oss/tests/pytest/integration/sessions/test_trigger_session_claim_postgres.py to verify the tests were running correctly before adding my refactoring changes, and then re-verified those same tests after making my changes. See screenshots below:

Test Results BEFORE changes

Test results logs

image

Generated test report

image

Test Results AFTER changes

Screenshot 2026-08-17 at 11 11 09 AM

Generated test report

image

Added or updated tests

N/A

Validation

api % ruff format oss/src/dbs/postgres/triggers/dao.py oss/src/dbs/postgres/triggers/upsert_utils.py oss/src/dbs/postgres/sessions/streams/dao.py
1 file reformatted, 2 files left unchanged

Note on linting: ruff check --fix run at the repo root currently reformats ~1,000+ files unrelated to this change (project-wide Optional/List X | None/list[...] modernization, import reordering, and removal of the # spacer-comment convention used throughout dao.py files). I did not apply those unrelated changes to keep this diff scoped to the #5934 refactor. Ran ruff format/ruff check --fix only against the new upsert_utils.py; the two edited DAO files were hand-verified against the existing house style instead.

QA follow-up

N/A

Demo

N/A, not a UI change (only refactoring)

Checklist

  • I have included a video or screen recording for UI changes, or marked Demo as N/A
  • Relevant tests pass locally
  • Relevant linting and formatting pass locally
  • I have signed the CLA, or I will sign it when the bot prompts me

Contributor Resources

Issue

Closes #5934

@vercel

vercel Bot commented Aug 15, 2026

Copy link
Copy Markdown

@oforiwaasam is attempting to deploy a commit to the agenta projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 24626843-f155-4689-baf4-76a727369bbf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@oforiwaasam
oforiwaasam marked this pull request as ready for review August 17, 2026 18:27
@oforiwaasam oforiwaasam changed the title Refactor/extract shared delivery upsert [Refactor] Extract shared delivery upsert Aug 17, 2026
@oforiwaasam oforiwaasam reopened this Aug 17, 2026
@oforiwaasam
oforiwaasam deleted the refactor/extract-shared-delivery-upsert branch August 22, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract a shared delivery-upsert builder in TriggersDAO

1 participant